<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增店铺信息')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-store-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">店铺名称
                ：</label>
            <div class="col-sm-8">
                <input name="storeName" class="form-control" type="text"                                       required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态
                ：</label>
            <div class="col-sm-8">
                <select name="storeStatus" class="form-control m-b"
                        th:with="type=${@dict.getType('sys_store_status')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">电话
                ：</label>
            <div class="col-sm-8">
                <input name="storeTel" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">联系人
                ：</label>
            <div class="col-sm-8">
                <input name="contacts" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">店铺地址
                ：</label>
            <div class="col-sm-8">
                <textarea name="storeAddress" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">营业执照
                ：</label>
            <div class="col-sm-8">
                <input type="hidden" name="imgUrl">
                <div class="file-loading">
                    <input class="form-control file-upload" id="imgUrl" name="file" type="file">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">主店铺
                ：</label>
            <div class="col-sm-8">
                <select name="storeMaster" class="form-control m-b"
                        th:with="type=${@dict.getType('app_enable_status')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">店铺头像
                ：</label>
            <div class="col-sm-8">
                <input type="hidden" name="storeImg">
                <div class="file-loading">
                    <input class="form-control file-upload" id="storeImg" name="file" type="file">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">创建时间
                ：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="createDate" class="form-control" placeholder="yyyy-MM-dd"
                           type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/store"
    $("#form-store-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-store-add').serialize());
        }
    }

    $("input[name='createDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })
</script>
</body>
</html>